"""
DatePickerCtrl
==============

`DatePickerCtrl` uses the `DateTime` class of wxPython as its value. Keep in
mind that this class is implemented in C++, and has quite a few differences from
the datetime class in Python's standard library.
"""
import wx
from wxpita import *

f = SizedFrame [
    DatePickerCtrl(name='dp1', dt=wx.DateTimeFromDMY(15, 3, 1933)),

    DatePickerCtrl(name='dp2', style='dp_dropdown'),

    TextCtrl(name='log', style='te_multiline', expand=True, proportion=1),
]

@f.Init
def _():
    dt = wx.DateTime_Today()
    dt.SubtractDS(wx.DateSpan(weeks=3)) # subtract 3 weeks
    f.dp2.SetValue(dt)

@f.dp1.date_changed
@f.dp2.date_changed
def _(evt):
    datestr = evt.GetDate().Format('%B %d, %Y')
    mesg = 'You changed <%s> to "%s"\n' % (evt.EventObject.GetName(), datestr)
    f.log.AppendText(mesg)

f.Show('DatePickerCtrl Example', size=(400, 400))
